<template>
	<view class="">
		<view class="cardContainer">
			<view class="mainInf">
				<view class="">
					{{shareInfo.name}}
				</view>
				<view class="avatar">
					<image :src="shareInfo.image" mode=""></image>
				</view>
			</view>
			<view class="callPhone">
				<view @tap="telphone(shareInfo.mobile)" class="">
					<image style="width: 26rpx;height: 26rpx;margin-right: 20rpx;"
						src="../../../static/images/yicha/phone.png" mode="">
					</image>
					打电话
				</view>
				<view @tap="copy(shareInfo.weixin)" class="">
					<image style="width: 28rpx;height: 24rpx;margin-right: 20rpx;"
						src="../../../static/images/yicha/wechat.png" mode="">
					</image>
					加微信
				</view>
			</view>
			<view class="" style="padding: 20rpx;margin-left: 30rpx;color: #939393;font-size: 26rpx;">
				{{shareInfo.desc}}
			</view>
		</view>
		<!-- <view class="shareLogList">
			<text class="shareTitle" v-if="shareInfo.user_id==userInfo.userid ">我的分享</text>
			<text class="shareTitle" v-else>他的分享</text>
			<view v-for="(i,n) in shareLogList" @click="toMainInfo(i)" class="shareInfo">
				<view class="shareinfoImage">
					<view class="title">
						{{i.art_info.name}}
					</view>
					<image :src="i.art_info.image" mode=""></image>
				</view>

				<text>阅读{{i.art_info.show_number}}</text>

			</view>
		</view> -->

	</view>
</template>

<script>
	export default {
		props: {
			// userid:String
		},
		data() {
			return {
				shareInfo: {},
				shareLogList: [],
				SpmResult: {},
				userInfo:{},
				userid: ''

			}
		},
		created() {
			if(window.location.href.indexOf('isShare=true') !== -1){
				this.userid=this.getLocationid()
			}else{
				this.userid=uni.getStorageSync('userInfo').id
			}
			this.loadCard()
			this.loadShareRecord()
		},
	
		methods: {
			getLocationid(){
					var x = location.href.split('userid=')[1]
					var userid = x.split('&')[0]
					return userid
			},
			loadCard() {
				this.$api.post({
					url: '/topic/shareInfo',
					data:{
						user_id:this.userid
					}
				}).then(res => {
					this.shareInfo = res
					uni.setStorageSync("setShareInfo", this.shareInfo);
				})
			},
			loadShareRecord() {

				this.$api.post({
					url: '/topic/shareLog',
					data:{
						user_id:this.userid
					}
				}).then(res => {
					console.log(res)
					this.shareLogList = res
				})
			},
			telphone(phone) {
				// 获取设备平台
				let platform = uni.getSystemInfoSync().platform
				switch (platform) {
					case 'android':
						uni.showActionSheet({
							itemList: [phone, '呼叫'],
							success: function(res) {
								console.log(res);
								if (res.tapIndex == 1) {
									plus.device.dial(phone, false)
								}
							},
							complete: function(res) {
								console.log("安卓失败", res)
							}
						})
						break;
					case 'ios':
						// 使用uni-app提供的借口
						uni.makePhoneCall({
							phoneNumber: phone

						})
						break;
					default:
						// 调试器工具
				}
			},

			copy(weixin) {
				uni.setClipboardData({
					data: weixin,
					// data:'https://d-yxcxh5.bigchun.com',
					success: data => {
						this.$u.toast('已复制到剪切板');

					}
				});
			},
			toMainInfo(i) {
				uni.navigateTo({
					url: '/pages/teacher/CourseVideo?id=' + i.share_id + '&isShare=true' + '&' + this.SpmResult
						.query
				})
			},
		}

	}
</script>

<style lang="scss">
	.cardContainer {
		border-radius: 24rpx;
		background: #fff;
		width: 670rpx;
		height: 580rpx;
		margin: 30rpx auto 46rpx;

		.mainInf {
			background: url('@/static/images/yicha/cardbg.png');
			background-size: 100% 100%;
			width: 100%;
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			font-size: 42rpx;
			font-weight: 500;
			color: #000;
			box-sizing: border-box;
			padding: 40rpx 50rpx;
			.avatar {
				width: 146rpx;
				height: 146rpx;
				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}

			}
		}

	}


	.callPhone {
		display: flex;
		justify-content: space-between;
		margin-top: 10px;
        padding: 0 40rpx;
		view {
			width: 125px;
			height: 40px;
			background: #FFFFFF;
			border: 1px solid #DCDCDC;
			border-radius: 22px;
			text-align: center;
			line-height: 40px;
		}

	}

	.shareLogList {
		background: #fff;
		padding: 40rpx 48rpx 120rpx;

		.shareTitle {
			position: relative;
		}

		.shareTitle::before {
			clear: both;
			position: absolute;
			content: '';
			width: 3px;
			height: 16px;
			background: linear-gradient(90deg, #98E05F, #0DE3AC);
			left: -8px;
			margin: auto;
			top: 0;
			bottom: 0;
		}

		.shareInfo {

			padding: 10px 0;
			border-bottom: 1px solid #e2e2e2;

			.shareinfoImage {
				display: flex;
				justify-content: space-between;

				image {
					width: 202rpx;
					height: 142rpx;
				}
			}

			.title {
				font-size: 16px;
				font-family: PingFang SC;
				font-weight: bold;
				color: #000000;
			}

			text {
				font-size: 13px;
				font-family: PingFang SC;
				font-weight: 400;
				color: #808080;
			}

		}

	}
</style>
